package com.viser.partyinrs.listadapters;

import java.util.ArrayList;

import com.viser.partyinrs.R;
import com.viser.partyinrs.entities.Post;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class PostoviListAdapter extends BaseAdapter {

	//adapter za izlistavanje postova
	
	ArrayList<Post> postovi;
	Activity context;
	
	
	
	public PostoviListAdapter(ArrayList<Post> postovi, Activity context) {
		super();
		this.postovi = postovi;
		this.context = context;
	}

	@Override
	public int getCount() {
		return postovi.size();
	}

	@Override
	public Object getItem(int position) {
		return postovi.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater inflater = context.getLayoutInflater();
		View layout = inflater.inflate(R.layout.post_item,parent, false);
		
		TextView txtKorisnik = (TextView) layout.findViewById(R.id.txtKorisnik);
		TextView txtNazivMesta = (TextView) layout.findViewById(R.id.txtNazivMesta);
		
		txtKorisnik.setText(((Post)getItem(position)).username);
		txtNazivMesta.setText(((Post)getItem(position)).nazivMesto);
		
		return layout;
	}

}
